package com.yociyy.admin.rpc;

import com.yociyy.admin.biz.BaseUserBiz;
import com.yociyy.admin.model.entity.BaseUser;
import com.yociyy.security.authentication.YoCiUser;
import com.yociyy.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统管理 - 用户模块 rpc
 * 
 * @author: YoCiyy
 * @date: 2020/4/21
 */
@RestController
@RequestMapping("rpc/user")
public class RemoteUserRest {

	@Autowired
	private BaseUserBiz userBiz;

	/**
	 * 通过用户登录账号查询用户信息
	 * 
	 * @param account 登录账号
	 * @return 用户信息
	 */
	@GetMapping("/{account}")
	public BaseUser selectUserByAccount(@PathVariable("account") String account) {
		return userBiz.getUserByAccount(account);
	};

	/**
	 * 当前登录用户信息
	 * 
	 * @return 用户信息
	 */
	@GetMapping("/info")
	public BaseUser selectLoginUser(Long userId) {
		YoCiUser user = SecurityUtils.getUser();
		return userBiz.getUserById(userId);
	}
}
